package ua.od.maxz;

import java.util.*;

/**
 * User: ua.od.maxz
 * Date: Jun 22, 2010
 * Time: 1:57:39 PM
 */
public class KillerW extends Killer {
    @Override
    protected String getCommandForTasksList() {
        return "jps";
    }

    @Override
    protected Collection<Integer> getPids(String processList) {
        String[] lines = processList.split("\n");
        Set<Integer> ret = new HashSet<Integer>();
        for (String line : lines) {
            if(line.contains("Bootstrap")) {
                int i = line.indexOf(" ");
                String pid = line.substring(0, i).trim();
                ret.add(Integer.parseInt(pid));
            }
        }
        return ret;
    }

    @Override
    protected String getKillCommand() {
        return "taskkill /F /PID ";
    }
}
